import 'package:erp/data/model/process_type.dart';
import 'package:erp/res/resources.dart';
import 'package:erp/util/image_utils.dart';
import 'package:erp/widgets/load_image.dart';
import 'package:erp/widgets/my_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 流程卡片
class FlowTemplateCard extends StatelessWidget {
  final Function(ProcessType processType)? onApplyTap;
  final Function? onSeeTap;
  final ProcessType processType;

  FlowTemplateCard({
    Key? key,
    this.onApplyTap,
    this.onSeeTap,
    required this.processType,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        image: DecorationImage(
          fit: BoxFit.fitWidth,
          image: ImageUtils.getImageProvider("", holderImg: 'flow/flow_card'),
        ),
      ),
      width: 686.w,
      height: 200.h,
      margin: EdgeInsets.fromLTRB(32.w, 29.w, 32.w, 0),
      child: Center(
        child: Container(
          margin: EdgeInsets.symmetric(horizontal: 10.w),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Container(
                padding: EdgeInsets.symmetric(horizontal: 20.w),
                width: 400.w,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      processType.typeName,
                      style: TextStyle(fontSize: 32.sp, color: Colours.white),
                    ),
                    Container(
                      margin: EdgeInsets.only(top: 20.w),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Container(
                            width: 140.w,
                            height: 40.h,
                            decoration: BoxDecoration(
                              border: Border.all(width: 1.w, color: Colours.white),
                              borderRadius: BorderRadius.all(Radius.circular(20.r)),
                            ),
                            child: MyButton(
                              radius: 20.r,
                              backgroundColor: Colors.transparent,
                              padding: EdgeInsets.zero,
                              text: '流程申请',
                              textColor: Colors.white,
                              fontSize: 20.sp,
                              onPressed: () {
                                if (onApplyTap != null) {
                                  onApplyTap!(processType);
                                }
                              },
                            ),
                          ),
                          SizedBox(width: 14.w),
                          GestureDetector(
                            onTap: () {
                              if (onSeeTap != null) {
                                onSeeTap!(processType);
                              }
                            },
                            child: LoadAssetImage(
                              'flow/eye',
                              width: 29.w,
                              height: 23.h,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
              LoadAssetImage(
                'flow/sale_project',
                width: 118.w,
                height: 134.h,
              )
            ],
          ),
        ),
      ),
    );
  }
}
